import bisect

class EventQueue:
    def __init__(self):
        self.events = []
    def insert(self, ev):
        bisect.insort(self.events, ev)

class Event:
    def __init__(self, point_index, point, seg_index=-1):
        self.pi = point_index
        self.point = point
        self.si = seg_index
    def __lt__(self, E):
        return self.point < E.point
    def __str__(self):
        return str(self.point)
    def __repr__(self):
        return self.__str__
